package dao.ProfileType;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import abstractFactory.Factory;
import model.ProfileType;

public class ProfileTypeDAOJPA implements ProfileTypeDAO{
	static EntityManager manager;

	public EntityManager getManager() {
		if(manager == null) {
			manager = Factory.getFactory().createEntityManager();
		}
		return manager;
	}


	public List<ProfileType> getAllProfileTypes() {
		Query query = (Query) getManager().createQuery("SELECT pf FROM ProfileType pf");
		@SuppressWarnings("unchecked")
		List<ProfileType> profileTypes =  query.getResultList();
		return profileTypes;
	}
}
